﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BizScore;
using System.Collections.Generic;
using BizScore.Model;
using Office;

namespace UnitTestProject1
{
    [TestClass]
    public class UnitTest2
    {
        [TestMethod]
        public void TestMethod1()
        {

            BizScore.Model.PostFinaNumber entity = new BizScore.Model.PostFinaNumber();
            entity.BKZW = "总计";
            entity.FinalNumber = (int)1.0d;
            Assert.AreEqual("", entity.PostID);


        }


        [TestMethod]
        public void TestMethod2_1()
        {

            BizScore.GetPostFinalNumber get = GetPostFinalNumber.GetInstance(@"D:\1.xlsx");
            var val = get.GetAllPostInfo();
        }


        [TestMethod]
        public void TestMethod2_3()
        {
            BizScore.GetExamScore get = GetExamScore.GetInstance(@"D:\2.xls", @"D:\3.xls");
            var val = get.GetAllExamineeInfo();
        }

        [TestMethod]
        public void TestMethod2_4()
        {
            BizScore.DataHandle handle = DataHandle.GetInstance();
            handle.SetPostInfoPath(@"D:\1.xlsx");
            handle.SetExamScorePath(@"D:\2.xls", @"D:\3.xls");
            handle.HandleData();
        }


        [TestMethod]
        public void TestMethod2_5()
        {
            List<PostFinaNumber> list = new List<PostFinaNumber>();

            ExcelSingle excel1 = new ExcelSingle();
            ExcelSingle excel2 = new ExcelSingle();

            //打开excel
            excel1.OpenExcel("D:\\1.xlsx");
            excel1.OpenExcelWorksheet("缴费开考数据");

            excel2.OpenExcel("D:\\2.xls");
            excel2.SaveAsExcelFile("D:\\3.xls", Excel.ExcelVersions.Excel_xls);
            excel2.OpenExcelWorksheet("Sheet1");

            //A列查找 报考职位
            //J 列查找 岗位最终拟招聘人数   
            int i = 2;
            
            PostFinaNumber entity = null;

            while (true)
            {
                entity = new PostFinaNumber();
                entity.BKZW = excel1.GetData("A" + i.ToString(), null).ToString();
                if (string.IsNullOrEmpty(entity.PostID)) break;
                entity.FinalNumber = int.Parse(excel1.GetData("J" + i.ToString(), null).ToString());
                list.Add(entity);
                i++;
            }


            //excel.CloseExcel(false);

            

         //   Excel.CloseAllExcel();

          


        }
    

    }
      
}
